#ifndef _UTILS_RECT_H_
# define _UTILS_RECT_H_

# include "config.h"
# include <SDL/SDL.h>
# include <stdexcept>

NS_BEGIN(SDL)
	NS_BEGIN(UTILS)

	class Rect
	{
	private:
		SDL_Rect m_rect;

	public:
		Rect(Sint16 _x = 0, Sint16 _y = 0, Uint16 _w = 0, Uint16 _h = 0);
		Rect(SDL_Rect const& _rect);
		Rect(Rect const& _rect);
		~Rect();

		Rect& operator=(Rect const& _rect);
		bool operator==(Rect const& _rect) const;
		bool operator!=(Rect const& _rect) const;

		static void InitSDLRect(SDL_Rect& _rect, Sint16 _x, Sint16 _y,
								Uint16 _w, Uint16 _h);
		static bool IsInArea(Rect const& _rect, Rect const& _area);

		void ToSDLRect(SDL_Rect& _rect) const;

		SDL_Rect const& GetRect() const;
		void SetRect(SDL_Rect const& _rect);
		Sint16 GetX() const;
		void SetX(Sint16 _x);
		Sint16 GetY() const;
		void SetY(Sint16 _y);
		Uint16 GetW() const;
		void SetW(Uint16 _w);
		Uint16 GetH() const;
		void SetH(Uint16 _h);

	public:
		__declspec(property(get=GetRect, put=SetRect)) SDL_Rect rect;
		__declspec(property(get=GetX, put=SetX)) Sint16 x;
		__declspec(property(get=GetY, put=SetY)) Sint16 y;
		__declspec(property(get=GetW, put=SetW)) Uint16 w;
		__declspec(property(get=GetH, put=SetH)) Uint16 h;
	};

	NS_END(UTILS)
NS_END(SDL)
#endif // _UTILS_RECT_H_
